/*
 * @Author: your name
 * @Date: 2021-06-26 17:41:38
 * @LastEditTime: 2021-06-26 18:37:48
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \hairdressing_web\src\services\youhuiquan\index.js
 */
import api from '../../common/config/api-url'
import Vue from 'vue'
export default {
  list: data => {
    return new Promise(resolve => {
      Vue.prototype.$u.get(api.youhuiquan.list, data).then(
        r => {
          if (r && r.code === 0) {
            resolve(r.data)
          }
        },
        e => {
          wx.showToast({
            title: e.msg,
            icon: 'none',
            duration: 2000
          })
        }
      )
    })
  },
  save: data => {
    return new Promise(resolve => {
      Vue.prototype.$u.post(api.youhuiquan.save + '?couponId=' + data).then(
        r => {
          if (r && r.code === 0) {
            resolve(r.data)
          }
        },
        e => {
          wx.showToast({
            title: e.msg,
            icon: 'none',
            duration: 2000
          })
        }
      )
    })
  },
  usableList: data => {
    return new Promise(resolve => {
      Vue.prototype.$u.get(api.youhuiquan.usableList, data).then(
        r => {
          if (r && r.code === 0) {
            resolve(r.data)
          }
        },
        e => {
          wx.showToast({
            title: e.msg,
            icon: 'none',
            duration: 2000
          })
        }
      )
    })
  },
  user: data => {
    return new Promise(resolve => {
      Vue.prototype.$u.get(api.youhuiquan.user, data).then(
        r => {
          if (r && r.code === 0) {
            resolve(r.data)
          }
        },
        e => {
          wx.showToast({
            title: e.msg,
            icon: 'none',
            duration: 2000
          })
        }
      )
    })
  },
}
